home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5996 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: undergrad.math.uwaterloo.ca!sckettle
  3. From: sckettle@undergrad.math.uwaterloo.ca (Steve Kettle)
  4. Subject: Re: delete
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <DMFBFn.nIC@undergrad.math.uwaterloo.ca>
  7. Date: Wed, 7 Feb 1996 20:54:59 GMT
  8. References: <DMDBqB.Bw5@undergrad.math.uwaterloo.ca> <31185EBB.41C67EA6@intellektik.informatik.th-darmstadt.de>
  9. Nntp-Posting-Host: noether.math.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <31185EBB.41C67EA6@intellektik.informatik.th-darmstadt.de>,
  13. Enno Sandner  <enno@intellektik.informatik.th-darmstadt.de> wrote:
  14. >Steve Kettle wrote:
  15. >> 
  16. >> The delete operator can be overloaded in a class by overloading with
  17. >> declaration
  18. >>         void operator delete(void*);
  19. >> 
  20. >> There is no way I see to set a pointer being deleted to 0 because of the
  21. >> pass by value.
  22. >> 
  23. >> Is there anyway to force a deleted pointer to be zero or are we just
  24. >> at mercy of the compiler implementation?
  25. >> --
  26. >
  27. >I don't know of any compiler that zeros the pointer-value when the
  28. >underlying object is deleted. Anyway unless you get completly rid of
  29. >ordinary pointers and replace them by wrappers there is no reasonable
  30. >way to mark an object as deleted. The remaining problem will always be
  31. >objects that are referred by more then one pointer.
  32. >
  33. >    Enno
  34.  
  35.      I don't know of any compiler which zeros the pointer either despite 
  36. what it says in the ARM:
  37.  
  38.      'Implementing the delete operator to modify the value of a
  39. deleted pointer can be useful for debugging by ensuring that a pointer 
  40. cannot be successfully used after being deleted.'
  41.  
  42.       Zeroing the pointer does not solve the multiple pointer to same 
  43. thing problem but at least it stops some dormant run time errors.  I 
  44. guess passing the deleted pointer by reference ( if it were allowed ) 
  45. would be a bad idea because of temporary  creation :
  46.     eg: 
  47.  
  48.     struct A{};
  49.     A a;
  50.     delete &a;  // ( temp pointer would be created here )
  51.  
  52. However I don't see any other problems with this idea.
  53.  
  54.  
  55.  
  56. -- 
  57.